package com.niannian.adapter;

import java.util.ArrayList;

import com.niannian.BaseActivity;
import com.niannian.MyApplication;
import com.niannian.R;
import com.niannian.activity.FamilyMemberDetailActivity;
import com.niannian.activity.FamilyNewsActivity;
import com.niannian.activity.MorePicShow;
import com.niannian.activity.MyInfoEditActivity;
import com.niannian.activity.OriginalImage;
import com.niannian.activity.PushCommentActivity;
import com.niannian.bean.FamilyNewsBean;
import com.niannian.bean.MyFamilyMemberBean;
import com.niannian.db.MyDBUser;
import com.niannian.dialog.YesNoDialog2;
import com.niannian.dialog.YesNoDialog2.onSimpleOnCancelListener;
import com.niannian.dialog.YesNoDialog2.onSimpleOnClicklListener;
import com.niannian.util.Common;
import com.niannian.util.PlayerManager;
import com.niannian.util.UserInfoManager;
import com.niannian.util.VAR;
import com.niannian.view.CircleImageView;
import com.niannian.view.MyListView;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class FamilyNewsAdapter extends BaseAdapter {
	protected MyDBUser userInfoManager = UserInfoManager.getUserInfoInstance();
	private ArrayList<FamilyNewsBean> fdatas;
	private LayoutInflater inflater;
	private Activity mActivity;
	private Handler handler;

	private BaseAdapter adapter;

	public FamilyNewsAdapter(Activity activity, Handler handler) {
		super();
		this.mActivity = activity;
		this.handler = handler;
		inflater = LayoutInflater.from(mActivity);

		this.fdatas = new ArrayList<FamilyNewsBean>();
	}

	@Override
	public int getCount() {
		return fdatas.size();
	}

	@Override
	public Object getItem(int arg0) {
		return fdatas.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	public ArrayList<FamilyNewsBean> getFDatasList() {
		return fdatas;
	}

	public void setAdapter(BaseAdapter adapter) {
		this.adapter = adapter;
	}

	View curView;

	@Override
	public View getView(final int position, View view, ViewGroup arg2) {
		ViewHolder holder = null;
		if (view == null) {
			view = inflater.inflate(R.layout.family_news_item, null);
			holder = new ViewHolder();
			holder.ll_itme_head = (LinearLayout) view.findViewById(R.id.ll_itme_head);
			holder.riv_avatar = (CircleImageView) view.findViewById(R.id.riv_avatar);
			holder.tv_user_name = (TextView) view.findViewById(R.id.tv_user_name);
			holder.tv_time = (TextView) view.findViewById(R.id.tv_time);

			holder.tv_aud_len = (TextView) view.findViewById(R.id.tv_aud_len);
			holder.btn_play = (RelativeLayout) view.findViewById(R.id.btn_play);
			holder.iv_status_play = (ImageView) view.findViewById(R.id.iv_status_play);

			holder.tv_family_news_info = (TextView) view.findViewById(R.id.tv_family_news_info);
			holder.tv_delete = (TextView) view.findViewById(R.id.tv_delete);
			holder.tv_comment = (TextView) view.findViewById(R.id.tv_comment);

			holder.crv_family_pic = (ImageView) view.findViewById(R.id.crv_family_pic);
			int max = (int) (BaseActivity.mScreenWidth * 0.6);
			holder.crv_family_pic.setMaxWidth(max);
			holder.crv_family_pic.setMaxWidth(max);
			int min = (int) (BaseActivity.mScreenWidth * 0.4);
			holder.crv_family_pic.setMinimumHeight(min);
			holder.crv_family_pic.setMinimumWidth(min);

			holder.list_fn_comment_content = (MyListView) view.findViewById(R.id.list_fn_comment_content);

			holder.tv_comment_bottom = (TextView) view.findViewById(R.id.tv_comment_bottom);
			holder.pb_fn_loading = (ProgressBar) view.findViewById(R.id.pb_fn_loading);

			holder.ll_family_pic = (LinearLayout) view.findViewById(R.id.ll_family_pic);
			holder.ll_family_pic1_3 = (LinearLayout) view.findViewById(R.id.ll_family_pic1_3);
			holder.ll_family_pic4_6 = (LinearLayout) view.findViewById(R.id.ll_family_pic4_6);
			holder.ll_family_pic7_9 = (LinearLayout) view.findViewById(R.id.ll_family_pic7_9);

			holder.crv_family_pic1 = (ImageView) view.findViewById(R.id.crv_family_pic1);
			holder.crv_family_pic2 = (ImageView) view.findViewById(R.id.crv_family_pic2);
			holder.crv_family_pic3 = (ImageView) view.findViewById(R.id.crv_family_pic3);
			holder.crv_family_pic4 = (ImageView) view.findViewById(R.id.crv_family_pic4);
			holder.crv_family_pic5 = (ImageView) view.findViewById(R.id.crv_family_pic5);
			holder.crv_family_pic6 = (ImageView) view.findViewById(R.id.crv_family_pic6);
			holder.crv_family_pic7 = (ImageView) view.findViewById(R.id.crv_family_pic7);
			holder.crv_family_pic8 = (ImageView) view.findViewById(R.id.crv_family_pic8);
			holder.crv_family_pic9 = (ImageView) view.findViewById(R.id.crv_family_pic9);

			int pich = (int) ((BaseActivity.mScreenWidth - Common.dip2px(mActivity, 64))/3);
			LayoutParams params = holder.crv_family_pic1.getLayoutParams();
			params.height = pich;
			params.width = pich;
			holder.crv_family_pic1.setLayoutParams(params);

			LayoutParams params2 = holder.crv_family_pic2.getLayoutParams();
			params2.height = pich;
			params2.width = pich;
			holder.crv_family_pic2.setLayoutParams(params2);
			holder.crv_family_pic3.setLayoutParams(params2);

			holder.crv_family_pic4.setLayoutParams(params);
			holder.crv_family_pic5.setLayoutParams(params2);
			holder.crv_family_pic6.setLayoutParams(params2);
			holder.crv_family_pic7.setLayoutParams(params);
			holder.crv_family_pic8.setLayoutParams(params2);
			holder.crv_family_pic9.setLayoutParams(params2);
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}
		final FamilyNewsBean fdata = fdatas.get(position);

		FamilyNewsCommentAdapter FNCommentAdapter = new FamilyNewsCommentAdapter(mActivity, handler, fdata);
		holder.list_fn_comment_content.setAdapter(FNCommentAdapter);
		FNCommentAdapter.setAdapter(adapter);

		try {
			if (fdata.getCommentBeans().size() > 0) {
				holder.tv_comment.setText("评论 " + fdata.getCommentBeans().size());
				holder.list_fn_comment_content.setVisibility(View.VISIBLE);
				holder.tv_comment_bottom.setVisibility(View.VISIBLE);
			} else {
				holder.tv_comment.setText("评论 0");
				holder.list_fn_comment_content.setVisibility(View.GONE);
				holder.tv_comment_bottom.setVisibility(View.GONE);
			}
		} catch (Exception e) {
			holder.tv_comment.setText("评论 0");
			holder.list_fn_comment_content.setVisibility(View.GONE);
			holder.tv_comment_bottom.setVisibility(View.GONE);
		}

		if (userInfoManager.id == fdata.getAuthor() || userInfoManager.family_perm == 1) {
			holder.tv_delete.setVisibility(View.VISIBLE);
		} else {
			holder.tv_delete.setVisibility(View.INVISIBLE);
		}

		holder.tv_user_name.setText(fdata.getAuthor_nickname());
		holder.tv_aud_len.setText(Common.showAudLen(fdata.getAud_len()));

		if (!Common.empty(fdata.getAud())) {
			holder.btn_play.setVisibility(View.VISIBLE);
			// 播放视图显示
			if (PlayerManager.getAudioPlayer(mActivity).currPlayingPath.equals(fdata.getAud())) {

				if (PlayerManager.getAudioPlayer(mActivity).isPlayStatus == 1) {
					holder.iv_status_play.setBackgroundResource(R.drawable.family_status_play_anim);
					AnimationDrawable anim = (AnimationDrawable) holder.iv_status_play.getBackground();
					anim.stop();
					anim.start();
				} else if (PlayerManager.getAudioPlayer(mActivity).isPlayStatus == 2) {
					holder.iv_status_play.setBackgroundResource(R.drawable.status_pause);
				} else {
					holder.iv_status_play.setBackgroundResource(R.drawable.play_3);
				}
			} else {
				holder.iv_status_play.setBackgroundResource(R.drawable.play_3);
			}
		} else {
			holder.btn_play.setVisibility(View.GONE);
		}

		if (PlayerManager.getAudioPlayer(mActivity).DownloadingMap.containsKey(fdata.getAud())) {
			holder.pb_fn_loading.setVisibility(View.VISIBLE);
		} else {
			holder.pb_fn_loading.setVisibility(View.GONE);
		}

		holder.tv_time.setText(Common.sgmdate(fdata.getCreated_time()));
		MyApplication.finalbitmap.display(holder.riv_avatar, Common.getAvatarThumbs(fdata.getAuthor_avatar()));

		if (!Common.empty(fdata.getInfo())) {
			holder.tv_family_news_info.setVisibility(View.VISIBLE);
			holder.tv_family_news_info.setText(fdata.getInfo());
		} else {
			holder.tv_family_news_info.setVisibility(View.GONE);
		}

		holder.crv_family_pic.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					Intent intent = new Intent(mActivity, OriginalImage.class);
					intent.putExtra("display", Common.getPublicImagesSmallUrl(fdata.getPic()));
					intent.putExtra("OriginalImageUrl", Common.getPublicImagesBigUrl(fdata.getPic()));
					mActivity.startActivity(intent);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});

		holder.btn_play.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {

					PlayerManager.getAudioPlayer(mActivity).aPlayer(adapter, fdata.getAud());
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});

		holder.riv_avatar.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				if (userInfoManager.id == fdata.getAuthor()) {
					Intent intent = new Intent(mActivity, MyInfoEditActivity.class);
					mActivity.startActivity(intent);
					mActivity.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
				} else {
					MyFamilyMemberBean fd = new MyFamilyMemberBean();
					fd.setId(fdata.getAuthor());
					fd.setFamily(fdata.getFamily());
					fd.setNickname(fdata.getAuthor_nickname());
					fd.setAvatar(fdata.getAuthor_avatar());

					Intent intent = new Intent(mActivity, FamilyMemberDetailActivity.class);
					intent.putExtra("position", position);
					intent.putExtra("data", fd);
					mActivity.startActivity(intent);
					mActivity.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
				}
			}
		});
		holder.tv_user_name.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				if (userInfoManager.id == fdata.getAuthor()) {
					Intent intent = new Intent(mActivity, MyInfoEditActivity.class);
					mActivity.startActivity(intent);
					mActivity.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
				} else {
					MyFamilyMemberBean fd = new MyFamilyMemberBean();
					fd.setId(fdata.getAuthor());
					fd.setFamily(fdata.getFamily());
					fd.setNickname(fdata.getAuthor_nickname());
					fd.setAvatar(fdata.getAuthor_avatar());

					Intent intent = new Intent(mActivity, FamilyMemberDetailActivity.class);
					intent.putExtra("position", position);
					intent.putExtra("data", fd);
					mActivity.startActivity(intent);
					mActivity.overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
				}
			}
		});

		holder.tv_delete.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				curView = (View) arg0.getParent().getParent().getParent();
				initDialog(fdata.getId(), position);
			}
		});

		holder.ll_itme_head.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
			}
		});

		holder.tv_comment.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					Intent intent = new Intent(mActivity, PushCommentActivity.class);
					intent.putExtra("fid", fdata.getId());
					mActivity.startActivityForResult(intent, FamilyNewsActivity.PUSH_COMMENT);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});

		holder.tv_comment_bottom.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					Intent intent = new Intent(mActivity, PushCommentActivity.class);
					intent.putExtra("fid", fdata.getId());
					mActivity.startActivityForResult(intent, FamilyNewsActivity.PUSH_COMMENT);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});

		if (fdata.getIsdelete() == 1 && curView != null) {
			removeListItem(curView, position);
		}

		if (fdata.getPic_num() == 0) {
			holder.crv_family_pic.setVisibility(View.GONE);
			holder.ll_family_pic.setVisibility(View.GONE);
		} else if (fdata.getPic_num() == 1) {
			holder.crv_family_pic.setVisibility(View.VISIBLE);
			holder.ll_family_pic.setVisibility(View.GONE);
			MyApplication.finalbitmap.display(holder.crv_family_pic, Common.getPublicImagesSmallUrl(fdata.getPic()));

		} else {
			holder.crv_family_pic.setVisibility(View.GONE);
			holder.ll_family_pic.setVisibility(View.VISIBLE);
			holder.ll_family_pic1_3.setVisibility(View.GONE);
			holder.ll_family_pic4_6.setVisibility(View.GONE);
			holder.ll_family_pic7_9.setVisibility(View.GONE);

			holder.crv_family_pic1.setVisibility(View.GONE);
			holder.crv_family_pic2.setVisibility(View.GONE);
			holder.crv_family_pic3.setVisibility(View.GONE);
			holder.crv_family_pic4.setVisibility(View.GONE);
			holder.crv_family_pic5.setVisibility(View.GONE);
			holder.crv_family_pic6.setVisibility(View.GONE);
			holder.crv_family_pic7.setVisibility(View.GONE);
			holder.crv_family_pic8.setVisibility(View.GONE);
			holder.crv_family_pic9.setVisibility(View.GONE);

			if (fdata.getPic_num() <= 3) {
				holder.ll_family_pic1_3.setVisibility(View.VISIBLE);
			} else if (fdata.getPic_num() <= 6) {
				holder.ll_family_pic1_3.setVisibility(View.VISIBLE);
				holder.ll_family_pic4_6.setVisibility(View.VISIBLE);
			} else if (fdata.getPic_num() <= 9) {
				holder.ll_family_pic1_3.setVisibility(View.VISIBLE);
				holder.ll_family_pic4_6.setVisibility(View.VISIBLE);
				holder.ll_family_pic7_9.setVisibility(View.VISIBLE);
			}
			String picPath = fdata.getPic().substring(0, fdata.getPic().length() - 4);

			for (int i = 0; i < fdata.getPic_num(); i++) {

				if (i == 0) {
					holder.crv_family_pic1.setVisibility(View.VISIBLE);
					MyApplication.finalbitmap.display(holder.crv_family_pic1, Common.getPublicImagesSmallUrl(fdata.getPic()));
				} else {

					switch (i + 1) {
					case 2:
						holder.crv_family_pic2.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic2, Common.getPublicImagesSmallUrl(picPath + "_1.jpg"));
						break;
					case 3:
						holder.crv_family_pic3.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic3, Common.getPublicImagesSmallUrl(picPath + "_2.jpg"));
						break;
					case 4:
						holder.crv_family_pic4.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic4, Common.getPublicImagesSmallUrl(picPath + "_3.jpg"));
						break;
					case 5:
						holder.crv_family_pic5.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic5, Common.getPublicImagesSmallUrl(picPath + "_4.jpg"));
						break;
					case 6:
						holder.crv_family_pic6.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic6, Common.getPublicImagesSmallUrl(picPath + "_5.jpg"));
						break;
					case 7:
						holder.crv_family_pic7.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic7, Common.getPublicImagesSmallUrl(picPath + "_6.jpg"));
						break;
					case 8:
						holder.crv_family_pic8.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic8, Common.getPublicImagesSmallUrl(picPath + "_7.jpg"));
						break;
					case 9:
						holder.crv_family_pic9.setVisibility(View.VISIBLE);
						MyApplication.finalbitmap.display(holder.crv_family_pic9, Common.getPublicImagesSmallUrl(picPath + "_8.jpg"));

					default:
						break;
					}

				}

			}
		}
		holder.crv_family_pic1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					//
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(fdata.getPic()));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(fdata.getPic()));

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 0;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);

					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_1.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_1.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 1;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);

					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_2.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_2.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 2;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic4.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_3.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_3.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 3;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic5.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_4.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_4.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 4;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic6.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_5.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_5.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 5;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic7.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_6.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_6.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 6;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);
					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic8.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_7.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_7.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 7;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);

					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});
		holder.crv_family_pic9.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (System.currentTimeMillis() - VAR.ExitTime > VAR.INTERVAL) {
					// Intent intent = new Intent(mActivity,
					// OriginalImage.class);
					// String picPath = fdata.getPic().substring(0,
					// fdata.getPic().length() - 4);
					// intent.putExtra("display",
					// Common.getPublicImagesSmallUrl(picPath + "_8.jpg"));
					// intent.putExtra("OriginalImageUrl",
					// Common.getPublicImagesBigUrl(picPath + "_8.jpg"));
					// mActivity.startActivity(intent);

					Intent intent = new Intent(mActivity, MorePicShow.class);

					intent.putExtra("display", fdata.getPic());
					intent.putExtra("picnum", fdata.getPic_num());
					int curpic = 8;
					intent.putExtra("curpic", curpic);
					mActivity.startActivity(intent);

					VAR.ExitTime = System.currentTimeMillis();
				}
			}
		});

		return view;

	}

	// 删除动态提示
	YesNoDialog2 tip;

	private void initDialog(final int id, final int position) {
		tip = new YesNoDialog2(mActivity, "确认要删除吗?");
		tip.setOnCancelListener(new onSimpleOnCancelListener() {

			@Override
			public void onCancel() {
				tip.dismiss();
			}
		});
		tip.setOnConfimClickListener(new onSimpleOnClicklListener() {

			@Override
			public void onClick() {
				Message msg = new Message();
				msg.what = FamilyNewsActivity.DELETE_NEWS;
				msg.arg1 = id;
				msg.arg2 = position;
				handler.sendMessage(msg);
				tip.dismiss();
				// removeListItem(curView, position);
			}
		});
		tip.show();
	}

	protected void removeListItem(View rowView, final int positon) {
		final Animation animation = (Animation) AnimationUtils.loadAnimation(rowView.getContext(), R.anim.item_anim);
		animation.setAnimationListener(new AnimationListener() {
			public void onAnimationStart(Animation animation) {
			}

			public void onAnimationRepeat(Animation animation) {
			}

			public void onAnimationEnd(Animation animation) {
				fdatas.remove(positon);
				notifyDataSetChanged();
				animation.cancel();
			}
		});

		rowView.startAnimation(animation);
	}

	class ViewHolder {
		LinearLayout ll_itme_head;
		CircleImageView riv_avatar;
		TextView tv_user_name;
		TextView tv_time;
		TextView tv_aud_len;
		RelativeLayout btn_play;
		ImageView iv_status_play;
		TextView tv_family_news_info;
		TextView tv_delete;
		TextView tv_comment;
		ImageView crv_family_pic;
		MyListView list_fn_comment_content;
		TextView tv_comment_bottom;
		ProgressBar pb_fn_loading;

		LinearLayout ll_family_pic, ll_family_pic1_3, ll_family_pic4_6, ll_family_pic7_9;
		ImageView crv_family_pic1, crv_family_pic2, crv_family_pic3, crv_family_pic4, crv_family_pic5, crv_family_pic6, crv_family_pic7, crv_family_pic8,
				crv_family_pic9;
	}

}
